{% extends 'base_with_top_menu.html' %}

{% load go_back_link %}

{% block title %}User list{% endblock %}

{% block header %}User list{% endblock %}

{% block content %}
    {% go_back_link "Go back" %}
    <div class='content_form'>
        <form action='.' method='post'>
            <table>
                <tr>
                    <td>First name: </td>
                    <td><input type='text' name='first_name' value='{{ search.first_name }}'></td>
                </tr><tr>
                    <td>Last name: </td>
                    <td><input type='text' name='last_name' value='{{ search.last_name }}'></td>
                </tr><tr>
                    <td>Email: </td>
                    <td><input type='text' name='email' value='{{ search.email|urlize }}'></td>
                </tr><tr>
                </tr><tr>
                    <td>Building:</td>
                    <td>
                        <select name="building">
                            {% for building in buildings %}
                                <option value={{ building.id }} {% if building.selected %} selected='selected' {% endif %} >
                                    {{ building.name }}
                                </option>
                            {% endfor %}
                        </select>
                    </td>
                </tr><tr>
                    <!-- <td></td> -->
                    <td> </td>
                    <td>
                        <input type='submit'  name='action' value='Search'>
                    </td>
                    <td>
                        <input type='checkbox' name='from_my_building' value='checked' {% if from_my_building %} checked='checked' {% endif %} >
                        From my building 
                    </td>
                </tr>
            </table>
        </form>
    </div>

    {% if perms.auth.add_user %}
    <div class="add_new_user">
      <a href="add/">Add new user</a>
    </div>
    {% endif %}
    
    <div style='margin-top: 1em'>
        <ul class='spaces'>
            {% for user in users %}
                <li><b><a href='{{ user.url }}'>{{user.username}}, {{ user.first_name }} {{ user.last_name }} ({{ user.email }})</a></b></li>
            {% endfor %}
            {% if non_found %} 
                No users found.
            {% endif %}
        </ul>
    </div>
{% endblock %}
